package com.practice.car.cardataapp.controller;

import com.practice.car.cardataapp.entity.frontEnd.Form;
import com.practice.car.cardataapp.service.*;
import com.practice.car.cardataapp.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * car-data-app project
 *
 * @author FlagDied
 * @date 2020/9/2
 */
@RestController
@RequestMapping("get")
public class DataController {
	@Autowired
	private CarSaleMonthService carSaleMonthService;

	//销售统计 CarSaleMonthDao
	@GetMapping("totalSale")
	public R total_sale() {
		List<Form> series = carSaleMonthService.getSeries();
		return R.create()
				.put("series", series);
	}

	//各月前十热门车辆占总销量比例
	@GetMapping("topTenProportion")
	public R topTenProportion() {
		return null;
	}

	@Autowired
	private CarPriceService carPriceService;

	//价格统计
	@GetMapping("price")
	public R price() {
		List<Form> series = carPriceService.getSeries();
		return R.create()
				.put("series", series);
	}

	@Autowired
	private CarBrandSaleService carBrandSaleService;

	//品牌销量
	@GetMapping("brandSale")
	public R brandSale() {
		List<Form> series = carBrandSaleService.getSeries();
		return R.create()
				.put("series", series);
	}

	@Autowired
	private CarSaleTrendService carSaleTrendService;

	//车型销量走势
	@GetMapping("carSaleTrend")
	public R carSaleTrend(@RequestParam("year") String year) {
		List<Form> series = carSaleTrendService.getSeries(year);
		return R.create()
				.put("series", series);
	}

	@Autowired
	private SuvAndMpvSalesService suvAndMpvSalesService;

	//SUV,MPV总销量占比
	@GetMapping("suvAndMpvSales")
	public R suvAndMpvSales() {
		List<Form> series = suvAndMpvSalesService.getSeries();
		return R.create()
				.put("series", series);
	}

	@Autowired
	private MpvNationalSaleService mpvNationalSaleService;

	//MPV各国系销量
	@GetMapping("mpvNationalSale")
	public R mpvNationalSale() {
		List<Form> series = mpvNationalSaleService.getSeries();
		return R.create()
				.put("series", series);
	}

	@Autowired
	private NationalCarSalesService nationalCarSalesService;

	//各国系销量走势
	@GetMapping("nationalCarSales")
	public R nationalCarSales(@RequestParam("year") String year) {
		List<Form> series = nationalCarSalesService.getSeries(year);
		return R.create()
				.put("series", series);
	}

	@Autowired
	private TotalNationalSaleService totalNationalSaleService;

	//各国系销量占比
	@GetMapping("totalNationalSale")
	public R totalNationalSale() {
		List<Form> series = totalNationalSaleService.getSeries();
		return R.create()
				.put("series", series);
	}

	@Autowired
	private SuvNationalSaleService suvNationalSaleService;

	//SUV各国系销量
	@GetMapping("suvNationalSale")
	public R suvNationalSale() {
		List<Form> series = suvNationalSaleService.getSeries();
		return R.create()
				.put("series", series);
	}

	@Autowired
	private CarSaleMonthTop10Service carSaleMonthTop10Service;
	//月销量前十汽车
	@GetMapping("carSaleMonthTopTen")
	public R carSaleMonthTopTen() {
		List<Form> series = carSaleMonthTop10Service.getSeries();
		return R.create()
				.put("series", series);
	}

	@Autowired
	private ComplaintService complaintService;
	//投诉查询
	@GetMapping("brandComplaintType")
	public R Complaint(@RequestParam("current") Integer page) {
		return complaintService.getChoice(page);

	}

	@Autowired
	private ComplaintRankingService complaintRankingService;
	//投诉排行
	@GetMapping("complaintRanking")
	public R Ranking(@RequestParam("current") Integer page) {
		return complaintRankingService.getChoice(page);
	}

	@Autowired
	private CarPlaceComplaintService carPlaceComplaintService;

	//城市投诉排行
	@GetMapping("carPlaceComplaint")
	public R CarPlaceComplaint(@RequestParam("current") Integer page) {
		return carPlaceComplaintService.getChoice(page);
	}

}
